#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "service.h"
#include <QDebug>
#include <HalconCpp.h>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    Ser::Service::Instance()->Deploy_ARI_ErrorRate("1");

//    connect(this,&MainWindow::read,[&](){
//        Ser::Service::Instance()->readImage();
//    });
//    int i=0;
//    auto loop = [&]() {
//        while (true) {
//            if (isRead)
//                break;
//            emit read();
//            //qDebug() << "读取::"<<i++;
//            std::this_thread::sleep_for(std::chrono::milliseconds(10));
//        }
//    };

//    this->readFuture = std::async(std::launch::async, loop);
    QVector<QString> list = cs.getPortNamelist();
    for(auto &l:list){
        qDebug() << l;
    }
    cs.openPort("COM3");
    cs.sendMsg("hello");
}

MainWindow::~MainWindow()
{
    isRead=true;
    delete ui;
}
